home *** CD-ROM | disk | FTP | other *** search
/ Experimental BBS Explossion 3 / Experimental BBS Explossion III.iso / c / pcw.zip / REST.C < prev    next >
Text File  |  1990-01-16  |  2KB  |  40 lines

  1. /***********************************************************/
  2. /* File Id.                  Rest.C                        */
  3. /* Author.                   Stan Milam.                   */
  4. /* Date Written.             02/14/89.                     */
  5. /*                                                         */
  6. /*           (c) Copyright 1989-90 by Stan Milam           */
  7. /*                                                         */
  8. /* Comments: This function replaces the wsleep() functions.*/
  9. /* it is provided to give delay capablity to all compilers */
  10. /* using this library.  Turbo C & Power C both have the    */
  11. /* sleep() function, in addition, Turbo C provides the     */
  12. /* delay() function.  However, Microsoft C has no delay    */
  13. /* type functions.                                         */
  14. /* This function works by multiplying the argument by 18   */
  15. /* (approximate for 18.2) and adding to it the BIOS time of*/
  16. /* day count kept in low memory.  Then simply wait for the */
  17. /* BIOS time of day count to catch up.                     */
  18. /***********************************************************/
  19.  
  20. #include <dos.h>
  21. #include "pcwproto.h"
  22.  
  23. void rest(unsigned ticks)  {
  24.  
  25.    long far *bios_count;                    /* Far pointer to BIOS count */
  26.    long anchor, control;                    /* Our anchor point */
  27.  
  28.    bios_count = (long far *) MK_FP(0x0000,0x046C); /* Point to TOD count */
  29.  
  30.    control= *bios_count;
  31.    anchor = control + ticks;
  32.  
  33.    while(*bios_count <= anchor) {           /* Wait for TOD to catch up */
  34.       if (*bios_count < control) {          /* Adjust if midnight rollover */
  35.          control = *bios_count;             /* Occurs. */
  36.          anchor -= 1573066L;
  37.       }
  38.    }
  39. }
  40.